#include "dialog.h"
#include "ui_dialog.h"


Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
{
    ui->setupUi(this);
}

Dialog::~Dialog()
{
    delete ui;
}


void Dialog::on_pushButton_stop_clicked()
{
  for(int i=0;i<MAXSIZE;i++)
  {
      workers[i]->terminate(); // 设置停止标志
      workers[i]->wait(); // 等待线程正常退出
  }
  ui->pushButton_stop->setEnabled(false);
  ui->pushButton_start->setEnabled(true);
}

void Dialog::on_pushButton_exit_clicked()
{
this->close();
}

void Dialog::on_pushButton_start_clicked()
{
    for(int i=0;i<MAXSIZE;i++)
    {
      workers[i]=new WorkerThread();

    }
    for(int i=0;i<MAXSIZE;i++)
    {
        workers[i]->start();
    }
    ui->pushButton_stop->setEnabled(true);
    ui->pushButton_start->setEnabled(false);

}
